﻿FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["DataServer/DataServer.WebApi/DataServer.WebApi.csproj", "DataServer/DataServer.WebApi/"]
COPY ["Swimj/Swimj.AspNetCore/Swimj.AspNetCore.csproj", "Swimj/Swimj.AspNetCore/"]
COPY ["Swimj/Swimj.Core/Swimj.Core.csproj", "Swimj/Swimj.Core/"]
COPY ["DataServer/DataServer.ApplicationLib/DataServer.ApplicationLib.csproj", "DataServer/DataServer.ApplicationLib/"]
COPY ["Swimj/Swimj.ApplicationLib/Swimj.ApplicationLib.csproj", "Swimj/Swimj.ApplicationLib/"]
COPY ["Swimj/Swimj.Data.Dapper/Swimj.Data.Dapper.csproj", "Swimj/Swimj.Data.Dapper/"]
COPY ["Swimj/Swimj.Data/Swimj.Data.csproj", "Swimj/Swimj.Data/"]
COPY ["DataServer/DataServer.CommonLib/DataServer.CommonLib.csproj", "DataServer/DataServer.CommonLib/"]
COPY ["Swimj/Swimj.CommonLib/Swimj.CommonLib.csproj", "Swimj/Swimj.CommonLib/"]
RUN dotnet restore "DataServer/DataServer.WebApi/DataServer.WebApi.csproj"
COPY . .
WORKDIR "/src/DataServer/DataServer.WebApi"
RUN dotnet build "DataServer.WebApi.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "DataServer.WebApi.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "DataServer.WebApi.dll"]
